<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>开通会员</title>
    <link type="text/css" rel="stylesheet" href="./layui/css/layui.css"/>
</head>
<body class="layui-layout-body">
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
    <legend>开通会员</legend>
</fieldset>
<div class="layui-body" style="left: 13px;margin-top: 68px;">
    <!-- 内容主体区域 -->
    <script type="text/javascript" src="layui/layui.all.js"></script>
    <div style="padding: 20px;">会员信息</div>
    <form class="layui-form" action="">

        <div class="layui-form-item">
            <label class="layui-form-label">会员姓名</label>
            <div class="layui-input-block">
                <input name="vname" lay-verify="title" autocomplete="off" placeholder="请输入会员姓名" class="layui-input  title"
                       type="text">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">会员密码</label>
            <div class="layui-input-block">
                <input name="vpwd" lay-verify="title" autocomplete="off" placeholder="请输入会员密码" class="layui-input  title"
                       type="text">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label state">会员性别(男?)</label>
            <div class="layui-input-block" style="padding-top: 13px">
                <input name="vsex" lay-skin="switch" lay-text="ON|OFF" type="checkbox" class="state">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">充值金额</label>
            <div class="layui-input-block">
                <input name="vrestmoney" lay-verify="title" autocomplete="off" placeholder="请输出充值金额" class="layui-input  title"
                       type="text">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">会员电话</label>
            <div class="layui-input-block">
                <input name="vphone" lay-verify="title" autocomplete="off" placeholder="请输入会员电话" class="layui-input  title"
                       type="text">
            </div>
        </div>



        <div class="layui-form-item">
            <div class="layui-input-block">
                <input type="button" class="layui-btn submit" value="确认开通">
            </div>
        </div>
    </form>
</div>

<script src="./layui/layui.all.js"></script>
<script type="text/javascript" src="./jquery-1.9.1.js"></script>
<script>
    layui.use('layedit', function () {
        var layedit = layui.layedit
            , $ = layui.jquery;

        //构建一个默认的编辑器
        var index = layedit.build('LAY_demo1');

    });
    //    var $ = layui.jquery;
    $(".submit").click(function () {
        console.log(".....")
        var $vname = $("input[name='vname']").val();
        var $vpwd = $("input[name='vpwd']").val();
        var $vrestmoney = $("input[name='vrestmoney']").val();
        var $vphone = $("input[name='vphone']").val();
        var $vsex = $(".state").serialize();
        if ($vsex === "") {
            $vsex = 0;
        } else {
            $vsex = 1;
        }

        var formdata = "vname=" + $vname + "&vpwd=" + $vpwd + "&vrestmoney=" + $vrestmoney + "&vphone=" + $vphone+"&vsex=" + $vsex;
        console.log(formdata);
        $.ajax({
            url: "/addvip.action",
            type: "POST",
            data: formdata
        }).done(function (data) {
            window.alert("开通成功");
        }).fail()
    });
</script>
</body>
</html>